import java.util.Scanner;

public class test2 {
    //小蓝有一个 01 矩阵。他打算将第一行第一列的 0 变为 2 。变化过程有传染性，每次
    //2 的上下左右四个相邻的位置中的 0 都会变成 2 。直到最后每个 2 的周围都是 1 或 2结束
    //请问，最终矩阵中有多少个 2 ？
    //0000100010000001101010101001001100000011
    //1000010000011101010110000000001011010100
    //0110101010110000000101100100000101001001
    //0000011010100000111111001101100010101001
    //0110000110000000110100000000010010100011
    //0100110010000110000000100010000101110000
    //0010011010100110001111001101100110100010
    //1111000111101000001110010001001011101101
    //0011110100011000000001101001101110100001
    //0000000101011000010011111001010011011100
    //0000100000011001000100101000111011101100
    //0010110000001000001010100011000010100011
    //0110110000100011011010011010001101011011
    //0000100100000001010000101100000000000010
    //0011001000001000000010011001100101000110
    //1110101000011000000100011001001100111010
    //0000100100111000001101001000001010010001
    //0100010010000110100001100000110111110101
    //1000001001100010011001111101011001110001
    //0000000010100101000000111100110010101101
    //0010110101001100000100000010000010110011
    //0000011101001001000111011000100111010100
    //0010001100100000011000101011000000010101
    //1001111010010110011010101110000000101110
    //0110011101000010100001000101001001100010
    //1101000000010010011001000100110010000101
    //1001100010100010000100000101111111111100
    //1001011010101100001000000011000110110000
    //0011000100011000010111101000101110110001
    //0101111001111101110111100000101010011111

    public static char[][] s = new char[30][40];
//    public static int[][] vis = new int[30][40];
    public static int[] dx = {-1, 1, 0, 0};
    public static int[] dy = {0, 0, -1, 1};

    public static void main(String[] args) {
        //输入
        Scanner scan = new Scanner(System.in);

        for (int i = 0; i < 30; i++) {
            String str1 = scan.next();
            s[i] = str1.toCharArray();
        }

        dfs(0, 0);

        int ret = 0;
        for (int i = 0; i < 30; i++) {
            for (int j = 0; j < 40; j++) {
                if (s[i][j] == '2') {
                    ret++;
                }
            }

        }
        System.out.println(ret);
    }

    private static void dfs(int x, int y) {
        if (x < 0 || x > 29 || y < 0 || y > 39 || s[x][y] != '0') {
            return;
        }
//        if(vis[x][y]==1){
//            return;
//        }
        s[x][y] = '2';
//        vis[x][y] = 1;
        for (int i = 0; i < 4; i++) {
            dfs(dx[i] + x, dy[i] + y);
        }

    }
}
